package com.bawei.module_apps.local


import com.bw.apps.local.entity.LocalAppsEntity

import io.virtualapp.hook_sdk.app.InstallAppUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn

class LocalAppsRepo{

    //查询本地应用
    fun selInstallApps():Flow<List<LocalAppsEntity>>{
        return flow {
            val datas = ArrayList<LocalAppsEntity>()
            //获得虚拟机上的本地app
            val list = InstallAppUtils().selInstalledApps()
            list.forEach{
                datas.add(LocalAppsEntity(it.packageName,it.apkPath,
                    it.libPath,it.dependSystem,it.appId,false,false))
            }
            emit(datas)
        }.flowOn(Dispatchers.IO)
    }

}